/*
 * These files are distributed under the terms of the GNU GPLv2, the GNU General
 * Public version 2. See LICENSE.txt
 */
package fileCommodore.plugin;

import org.apache.commons.vfs.*;

import fileCommodore.view.*;

public abstract class PanePlugin extends Plugin
{
	private FilePane pane;
	
	public void setPane( FilePane pane )
	{
		this.pane = pane;
	}
	
	@Override
	public final void activeSelectionChanged()
	{
		if (pane.isActive())
		{
			selectionChanged();
		}
	}
	
	@Override
	public final void inactiveSelectionChanged()
	{
		if (!pane.isActive())
		{
			selectionChanged();
		}
	}
	
	public abstract void selectionChanged();
	
	public Selection getSelection()
	{
		Selection retval =
				pane.isActive() ? getActiveSelection() : getInactiveSelection();
		
		return retval;
	}
	
	public void changeTo( FileObject path ) throws FileSystemException
	{
		if (pane.isActive())
		{
			changeActiveTo( path );
		}
		else
		{
			changeInactiveTo( path );
		}
	}
	
	public void changeTo( String path ) throws FileSystemException
	{
		if (pane.isActive())
		{
			changeActiveTo( path );
		}
		else
		{
			changeInactiveTo( path );
		}
	}
}
